package com.foreknow.service.impl;

import com.foreknow.dao.UserMapper;
import com.foreknow.entity.User;
import com.foreknow.service.UserService;
import com.foreknow.utils.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service

public class UserSerivcrImpl implements UserService {
    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public User Login(String username, String password) {

        return userMapper.Login(username, password);
    }



    @Override
    public List<User> queryAllUser(String query) {
        return userMapper.findUser(query);
    }

    @Override
    public boolean deleteUserById(Integer id) {return userMapper.deleteUserById(id) == 1;}

    @Override
    public boolean updateUser(User user) {
        return userMapper.updateUser(user) == 1;
    }

    @Override
    public boolean addUser(User user) { return userMapper.insertSelective(user) == 1; }

    @Override
    public Integer deleteUsers(List<Integer> ids) {
        return userMapper.deleteAllById(ids);
    }

    @Override
    public User findUserById(Integer id) {
        return userMapper.findUserById(id);
    }


}
